#include<bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int n,m,lim,a[114][114];
string s[N],t[N];
inline bool ok(int i,int j){return ~i&&~j&&i<n&&j<m&&t[i][j]=='1';}
int main(){
	freopen("indian.in","r",stdin);
	freopen("indian.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;
	for(int i=0;i<n;++i){
		cin>>s[i];
		int base=i*2%3;
		for(int j=0;j<m;++j){
			if(s[i][j]=='#'&&j%3==base) t[i]+='1';
			else t[i]+=(s[i][j]=='#'?'0':'.');
			lim+=(s[i][j]=='#')+(i==0||s[i-1][j]!=s[i][j])+(j==0||s[i][j-1]!=s[i][j]);
			lim+=(s[i][j]=='#')*(i==n-1||j==m-1);
		}
	}
	lim/=5;
	for(int i=0;i<n;++i)
	for(int j=0;j<m;++j)
		if(t[i][j]=='0'&&!ok(i-1,j)&&!ok(i+1,j)&&!ok(i,j-1)&&!ok(i,j+1)) t[i][j]='1';
	for(int i=0;i<n;++i) cout<<t[i]<<'\n';
	return 0;
}


